package w3

import scala.collection.mutable
import scala.io.StdIn
import scala.collection.mutable._

class A {
  private var sname: String = "t";
  private var map = new mutable.HashMap[String, String]()

  def update(i: Int, v: String): Unit = {
    sname += v
  }

  def update(i: String, v: String): Unit = {
    map(i) = v
  }

  override def toString: String = sname + "," + map
}

object TestMap2 {
  def main(args: Array[String]): Unit = {
    var a = new A()
    a(2) = "sss"
    a("dog") = "小狗"
    println(a)
    var m = Map("狗" -> "dog", "猪" -> "pig", "牛" -> "cow")
    val eng = StdIn.readLine("请输入英文：")
    m.find(_._2 == eng) match {
      case Some(value) => {
        println(value)
      }
      case None => println("没有找到")
    }
    var k: String = null
    for ((x, y) <- m) {
      if (eng == y) {
        println(x)
        k = x
      }
    }

  }
}
